package com.example.keli.ui.my.adapter;

import android.content.Context;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.keli.R;
import com.example.keli.base.utils.DensityUtil;
import com.example.keli.base.utils.GlideUtil;
import com.example.keli.base.utils.ScreenUtil;
import com.example.keli.base.widget.RoundWhiteImageView;
import com.example.keli.ui.my.model.LoveReciveBean;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * description:
 * author: Allen
 * date: 2019/3/19 11:51
 */
public class LoveReceiveAdapter extends BaseQuickAdapter<LoveReciveBean.DataBean, BaseViewHolder> {

    int width = 173 * 2;
    int height = 220 * 2;
    @BindView(R.id.iv_cover)
    ImageView ivCover;
    @BindView(R.id.tv_love_title)
    TextView tvLoveTitle;
    @BindView(R.id.tv_love_city)
    TextView tvLoveCity;
    @BindView(R.id.rl_love)
    RelativeLayout rlLove;
    @BindView(R.id.ll_image)
    LinearLayout llImage;
    @BindView(R.id.iv_avatar)
    RoundWhiteImageView ivAvatar;
    @BindView(R.id.tv_num)
    TextView tvNum;

    private Context mContext;

    public LoveReceiveAdapter(List<LoveReciveBean.DataBean> mData, Context context) {
        super(R.layout.item_recive_love, mData);
        this.mContext = context;
        width = (ScreenUtil.getScreenWidth(context) - DensityUtil.dip2px(context, 30)) / 2;
        height = width * 220 / 173;
    }

    @Override
    protected void convert(BaseViewHolder helper, LoveReciveBean.DataBean mListBean) {
        helper.setText(R.id.tv_love_title, mListBean.getTitle());
        helper.setText(R.id.tv_love_city, mListBean.getRegion_name());
        helper.setText(R.id.tv_tickets_num, String.format(mListBean.getTicket_num()+"%s","票"));
        helper.setText(R.id.tv_num, String.format("查看全部  %s %s", mListBean.getLike_num(), "人"));

//        List<LoveReciveBean.DataBean.UserInfoBean> datas = new ArrayList<>(mListBean.getUserInfo());
//        for (int i=0; i<datas.size(); i++){
//            if (i<3){
//                LinearLayout layout = helper.getView(R.id.ll_image);
//                ImageView imageView = new ImageView(mContext);
//                imageView.setLayoutParams(new ViewGroup.LayoutParams(DensityUtil.dip2px(mContext, 40), DensityUtil.dip2px(mContext, 40)));
//                GlideUtil.displayCircle(mContext, imageView, datas.get(i).getAvatar());
//                LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
//                        ViewGroup.LayoutParams.WRAP_CONTENT));
//                layoutParams.leftMargin = 15;
//                layoutParams.rightMargin = 15;
//                layoutParams.bottomMargin = 20;
//                layout.addView(imageView, layoutParams);
//            }
//        }

        ImageView cover = helper.getView(R.id.iv_cover);
        GlideUtil.display(cover.getContext(), cover, mListBean.getCover_picture());
    }

}
